<div id="bar" style="width: 500px;height:400px;margin: 0 auto"></div>
<script>
    var bar = echarts.init(document.getElementById('bar'));
    bar.setOption({
        title: {
            text: '每日用户活跃数',
            subtext: '日用户流量'
        },
        legend: {
            data:['用户数']
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'cross'
            }
        },
        toolbox: {
            show: true,
            feature: {
                dataView: {readOnly: false},
                magicType: {type: ['line', 'bar']},
                restore: {},
                saveAsImage: {}
            }
        },
    });
    $.ajax({
        type:'get',
        url:'bar',
        cache: false,
        success:function(data){
            console.log(data);
            bar.setOption({
                xAxis:  {
                    type: 'category',
                    boundaryGap: false,
                    data: data.time
                },
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value}'
                    },
                    axisPointer: {
                        snap: true
                    }
                },
                series: [
                    {
                        name:'日流量',
                        type:'line',
                        smooth: true,
                        data: data.counts,
                    }
                ]
            });
        },
        error:function(data){
            return false
        }
    });

</script>